package com.demo.java.deferred;

import com.stumbleupon.async.Deferred;

import java.util.ArrayList;
import java.util.List;

public class DeferredTest {

    public static void main(String[] args) throws Exception {
        Deferred<Object> deferred1 = Deferred.fromResult("123");
        Deferred<Object> deferred2 = Deferred.fromResult("456");
        Deferred<Object> deferred3 = Deferred.fromResult("789");

        List<Deferred<Object>> deferreds = new ArrayList<>();
        deferreds.add(deferred1);
        deferreds.add(deferred2);
        deferreds.add(deferred3);
        List<Object> result = Deferred.group(deferreds).join();
        result.stream().forEach(x -> System.out.println(x));

    }
}
